package com.weblog.article.client;

import com.weblog.article.client.factory.UserFallBackFactory;
import com.weblog.article.client.impl.UserClientImpl;
import com.weblog.article.interceptor.FeignInterceptor;
import entity.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author MaoLin Wang
 * @date 2019/9/2215:37
 */
@FeignClient(value = "weblog-user",fallbackFactory = UserFallBackFactory.class,configuration = FeignInterceptor.class)
public interface UserClient {

    /**
     * 根据id查询用户名
     * @param id
     * @return
     */
    @GetMapping("/user/client/{id}")
    Result findUserNameById(@PathVariable String id);

    @GetMapping("/access/{targetRole}/{targetPermission}")
    Result isAccess(@PathVariable("targetRole") String targetRole, @PathVariable("targetPermission") String targetPermission);


    /**
     * 增加积分
     * @param
     * @return
     */
    @PutMapping("user/client/score/{id}")
     Result incrScore(@PathVariable("id")String id,@RequestParam("score")int score);

    /**
     * 根据分类id查询该分类的所有文章
     * @param userId 用户id
     * @param id 分类id
     * @return
     */
    @GetMapping("cuscategory/client/aids/{userId}/{id}")
     Result articleInfo(@PathVariable String userId,@PathVariable String id);
}
